package city.spring.modules.work.vo;

import city.spring.modules.work.action.model.AbstractPlanShift;
import city.spring.modules.work.entity.WorkPlanShiftExtEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.time.LocalTime;

/**
 * @author HouKunLin
 * @date 2020/6/4 0004 16:48
 * @see WorkPlanShiftExtEntity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class WorkPlanShiftVO extends WorkPlanShiftExtEntity {
    /**
     * 班次名称
     */
    private String title;

    /**
     * 该班次上班开始时间
     */
    private LocalTime startTime;

    /**
     * 该班次上班结束时间
     */
    private LocalTime endTime;

    /**
     * 转换成排班时所需要的对象
     *
     * @return AbstractPlanShift
     */
    public AbstractPlanShift<WorkPlanShiftVO> toPlanShift() {
        WorkPlanShiftVO item = this;
        return new AbstractPlanShift<WorkPlanShiftVO>() {
            @Override
            public Object getKey() {
                return item.getWorkShiftId();
            }

            @Override
            public String getTitle() {
                return item.getTitle();
            }

            @Override
            public int getWorkNumber() {
                return item.getWorkNumber();
            }

            @Override
            public boolean isTomorrowNotWork() {
                return item.isTomorrowNotWork();
            }

            @Override
            public WorkPlanShiftVO getObject() {
                return item;
            }
        };
    }

    @Override
    public String toString() {
        return super.toString();
    }
}
